package com.retirement.staff.controller;

import com.retirement.common.core.controller.BaseController;
import com.retirement.common.core.domain.AjaxResult;
import com.retirement.common.core.page.TableDataInfo;
import com.retirement.staff.domain.OldStaff;
import com.retirement.staff.dto.OldStaffDto;
import com.retirement.staff.service.IOldStaffService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lijy
 * @since 2023-12-28
 */
@Api(value = "员工信息管理", tags = "员工信息管理")
@RequiredArgsConstructor
@RestController
@RequestMapping("/staff")
public class OldStaffController extends BaseController {

    private final IOldStaffService iOldStaffService;

    @GetMapping("/page")
    @ApiOperation(value = "分页查询基础信息")
    public TableDataInfo listOldStaff(OldStaffDto dto){
        startPage();
        return getDataTable(iOldStaffService.listOldStaff(dto));
    }

    @PostMapping
    @ApiOperation(value = "新增员工信息")
    public AjaxResult addOldStaff(@RequestBody OldStaff dto){
        return AjaxResult.success(iOldStaffService.addOldStaff(dto));
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "查询员工详情")
    public OldStaff getDetail(@PathVariable("id") String id){
        return iOldStaffService.getDetail(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除员工信息")
    public AjaxResult deleteStaff(@PathVariable("id") String id){
        return AjaxResult.success(iOldStaffService.deleteStaff(id));
    }

    @PutMapping
    @ApiOperation(value = "修改员工信息")
    public AjaxResult updateStaff(@RequestBody OldStaff dto){
        return AjaxResult.success(iOldStaffService.updateStaff(dto));
    }

    @DeleteMapping("/{userIds}")
    @ApiOperation("批量删除员工信息")
    public AjaxResult deleteStaffByIds(@PathVariable("id") String[] ids){
        return AjaxResult.success(iOldStaffService.deleteUserByIds(ids));
    }

}
